/**
 * @Author: Sun Rising
 * @Date: 2020-07-02 08:24:40
 * @Last Modified by: Sun Rising
 * @Last Modified time: 2020-07-02 08:25:00
 * @Description: 工厂模式
 */
// 基础接口
interface People {
    sayHello();
}

// 女人
class Woman implements People {

    sayHello() {
        console.log('Hello i am Woman！');
    }

}

// 男人
class Man implements People {

    sayHello() {
        console.log('Hello i am Man');
    }

}

// 工厂
class Factory {
    static Woman = 'Woman'
    static Man = "Man"
    static getPeople(type) {
        if (type === Factory.Woman)
            return new Woman()
        if (type === Factory.Man)
            return new Man()
        else
            return null
    }
}

let woman = Factory.getPeople(Factory.Woman)
woman.sayHello()
let man = Factory.getPeople(Factory.Man)
man.sayHello()


